package JUC.lock;

import java.util.concurrent.TimeUnit;

/**
 * @author mubei
 * @date 2021/11/21
 * @description
 * 1. 标准情况下 两个线程先打印  发短信 还是 打电话?
 * 2.发短信内部延迟4秒  两个线程先打印  发短信 还是 打电话?
 */
public class Test1 {


    public static void main(String[] args) {

        Phone phone = new Phone();
        new Thread(()-> phone.sendSms(),"A").start();
        try {
            TimeUnit.SECONDS.sleep(1);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        new Thread(()-> phone.call(),"A").start();
    }

}


class Phone{


    public synchronized void sendSms(){
        System.out.println("发短信");
    }

    public synchronized void call(){
        System.out.println("call");
    }
}
